package GUI;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;



@SuppressWarnings("serial")
/**
 * Librarian's sidebar containing all of its commands
 * @author Benny
 *
 */
public class LibrarianSideBarGUI extends SideBar {
	public ImageIcon img;
	/**
	 * Create the panel.
	 * @param M Instance of the main Frame of the program
	 */	
	public LibrarianSideBarGUI(MainFrame M) {
		super(M);


		JButton btnReturnBook = new JButton("Return Book");
		btnReturnBook.setBounds(10, 11, 160, 44);
		add(btnReturnBook);
		
		btnReturnBook.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0){
	
				mf.librarianMain.bookReturn.init();
				mf.librarianMain.bookReturn.setVisible(true);
				mf.librarianMain.registerNewUser.setVisible(false);
				mf.librarianMain.manualExtend.setVisible(false);
				mf.librarianMain.searchBook.setVisible(false);
				mf.librarianMain.viewUser.setVisible(false);
				mf.librarianMain.bookBorrow.setVisible(false);
				mf.librarianMain.addBook.setVisible(false);
				mf.managerMain.activityGUI.setVisible(false);
				mf.managerMain.reports.setVisible(false);
				mf.managerMain.cardManaging.setVisible(false);
				mf.managerMain.regBorrowGUI.setVisible(false);
		
			}
		});
		
		JButton btnAddNewUser = new JButton("Add New User");
		btnAddNewUser.setBounds(10, 66, 160, 44);
		add(btnAddNewUser);
		
		btnAddNewUser.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0){
				mf.librarianMain.registerNewUser.init();
				mf.librarianMain.registerNewUser.setVisible(true);
				mf.librarianMain.bookReturn.setVisible(false);
				mf.librarianMain.manualExtend.setVisible(false);
				mf.librarianMain.searchBook.setVisible(false);
				mf.librarianMain.viewUser.setVisible(false);
				mf.librarianMain.bookBorrow.setVisible(false);
				mf.librarianMain.addBook.setVisible(false);
				mf.managerMain.activityGUI.setVisible(false);
				mf.managerMain.reports.setVisible(false);
				mf.managerMain.cardManaging.setVisible(false);
				mf.managerMain.regBorrowGUI.setVisible(false);
			}
		});
		
		JButton btnSearchBook = new JButton("Search Book");
		btnSearchBook.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0){
				mf.librarianMain.searchBook.init();
				mf.librarianMain.searchBook.setVisible(true);
				mf.librarianMain.bookReturn.setVisible(false);
				mf.librarianMain.manualExtend.setVisible(false);
				mf.librarianMain.registerNewUser.setVisible(false);
				mf.librarianMain.viewUser.setVisible(false);
				mf.librarianMain.bookBorrow.setVisible(false);
				mf.librarianMain.addBook.setVisible(false);
				mf.managerMain.activityGUI.setVisible(false);
				mf.managerMain.reports.setVisible(false);
				mf.managerMain.cardManaging.setVisible(false);
				mf.managerMain.regBorrowGUI.setVisible(false);
				
				for (int i = mf.librarianMain.searchBook.searchTableModel1.getRowCount() - 1; i >= 0; i--)
					 mf.librarianMain.searchBook.searchTableModel1.removeRow(i);
				for (int i = mf.librarianMain.searchBook.searchTableModel.getRowCount() - 1; i >= 0; i--)
					 mf.librarianMain.searchBook.searchTableModel.removeRow(i);
			}
		});
		btnSearchBook.setBounds(10, 121, 160, 44);
		add(btnSearchBook);
		
		JButton btnBorrowBook = new JButton("Borrow Book");
		btnBorrowBook.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				mf.librarianMain.bookBorrow.init();
				mf.librarianMain.bookBorrow.setVisible(true);
				mf.librarianMain.bookReturn.setVisible(false);
				mf.librarianMain.manualExtend.setVisible(false);
				mf.librarianMain.searchBook.setVisible(false);
				mf.librarianMain.viewUser.setVisible(false);
				mf.librarianMain.registerNewUser.setVisible(false);
				mf.librarianMain.addBook.setVisible(false);
				mf.managerMain.activityGUI.setVisible(false);
				mf.managerMain.reports.setVisible(false);
				mf.managerMain.cardManaging.setVisible(false);
				mf.managerMain.regBorrowGUI.setVisible(false);
			}
		});
		btnBorrowBook.setBounds(10, 176, 161, 44);
		add(btnBorrowBook);
		
		JButton btnAddBook = new JButton("Add Book");
		btnAddBook.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				mf.librarianMain.addBook.init();
				mf.librarianMain.bookReturn.setVisible(false);
				mf.librarianMain.bookBorrow.setVisible(false);
				mf.librarianMain.manualExtend.setVisible(false);
				mf.librarianMain.searchBook.setVisible(false);
				mf.librarianMain.viewUser.setVisible(false);
				mf.librarianMain.registerNewUser.setVisible(false);
				mf.librarianMain.addBook.setVisible(true);
				mf.managerMain.activityGUI.setVisible(false);
				mf.managerMain.reports.setVisible(false);
				mf.managerMain.cardManaging.setVisible(false);
				mf.managerMain.regBorrowGUI.setVisible(false);
			}
		});
		btnAddBook.setBounds(10, 231, 160, 44);
		add(btnAddBook);
		
		JButton btnViewuser = new JButton("View User");
		btnViewuser.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				mf.librarianMain.viewUser.init();
				mf.librarianMain.viewUser.setVisible(true);
				mf.librarianMain.bookReturn.setVisible(false);
				mf.librarianMain.bookBorrow.setVisible(false);
				mf.librarianMain.manualExtend.setVisible(false);
				mf.librarianMain.searchBook.setVisible(false);
				mf.librarianMain.registerNewUser.setVisible(false);
				mf.librarianMain.addBook.setVisible(false);
				mf.managerMain.activityGUI.setVisible(false);
				mf.managerMain.reports.setVisible(false);
				mf.managerMain.cardManaging.setVisible(false);
				mf.managerMain.regBorrowGUI.setVisible(false);
			}
		});
		btnViewuser.setBounds(10, 286, 160, 44);
		add(btnViewuser);
		
		JButton btnExtendBook = new JButton("Extend Book");
		btnExtendBook.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				mf.librarianMain.manualExtend.init();
				mf.librarianMain.manualExtend.setVisible(true);
				mf.librarianMain.bookReturn.setVisible(false);
				mf.librarianMain.bookBorrow.setVisible(false);
				mf.librarianMain.viewUser.setVisible(false);
				mf.librarianMain.searchBook.setVisible(false);
				mf.librarianMain.registerNewUser.setVisible(false);
				mf.librarianMain.addBook.setVisible(false);
				mf.managerMain.activityGUI.setVisible(false);
				mf.managerMain.reports.setVisible(false);
				mf.managerMain.cardManaging.setVisible(false);
				mf.managerMain.regBorrowGUI.setVisible(false);
			}
		});
		btnExtendBook.setBounds(10, 341, 161, 44);
		add(btnExtendBook);
		
		 img = new ImageIcon(getClass().getResource(
                "/util/grad.png"));
		JLabel picLabel = new JLabel(img);
		picLabel.setLocation(0, 0);
		picLabel.setSize(185, 580);

	}
}
